
<?php
    $url = new Url();
    $arr_region = LoadConfig::$region;

    //var_dump($arr_region);
?>
<script type="text/javascript">

    loadBoxThongke();

    loadBoxKetQua();

    loadBoxTienIch();

    function loadBoxKetQua(){
        var url = "<?=$url->createUrl('home/boxketqua');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxketqua").html(msg);
            }
        });
    }

    function loadBoxTienIch(){
        var url = "<?=$url->createUrl('home/boxtienich');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxtienich").html(msg);
            }
        });
    }

    function loadBoxThongke(){
        var url = "<?=$url->createUrl('home/boxthongke');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxthongke").html(msg);
            }
        });
    }

    function login(){
        var url = "<?=$url->createUrl('user/index');?>";
        var username = $('#username').val();
        var password = $('#password').val();
        var remember = $('#remember').prop('checked');
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{
                username: username,
                password: password,
                remember: remember,
            },
            success: function(msg){
                if(msg==1){
                    alert('Đăng nhập thành công');
                    window.location = "<?php echo Yii::app()->createUrl('home/index');?>";
                }
                else{
                    $('#error').html(msg);
                }
            }
        });
    }

</script>

<div class="leftMain">
    <div class="titleCHAT">
        Đăng nhập
    </div>
    <div class="SM">
        <table width="100%" class="Login">
            <tr>
                <td width="25%"><b>Tài khoản / Mobile :</b></td>
                <td width="33%">
                    <input type="text" value="<?php if($username!=""){echo $username;}?>" id="username" class="boxSearch" style="background: #fff;">
                </td>
                <td width="33%" rowspan="4" valign="top" style="padding: 15px;">
            </tr>
            <tr>
                <td width="25%"><b>Mật khẩu :</b></td>
                <td width="33%">
                    <input type="password" value="<?php if($username!=""){echo $password;}?>" id="password" class="boxSearch" style="background: #fff;">
                </td>
            </tr>
            <tr>
                <td width="25%"></td>
                <td width="33%">
                    <input id="remember" <?php if($username!=""){echo "checked='checked'";}?> type="checkbox"><span style="font-size: 12px;">Ghi nhớ mật khẩu</span>
                    <br>
                    <span class="error" id="error"></span>
                </td>
            </tr>
            <tr>
                <td width="25%"></td>
                <td width="33%">
                    </br>
                    <a href="javascript:void(0);" onclick="login();" class="button_KQ_1">Đăng nhập</a>
                    &nbsp;&nbsp;
                    <a href="<?php echo Yii::app()->createUrl('user/register')?>" class="button_KQ_2">Đăng ký</a>
                </td>
            </tr>
        </table>
        <p>Nếu bạn quên mật khẩu?</p>
        <p>Soạn tin </p>
    </div>
</div>
<div class="rightMain">
    <div class="Box" id="boxketqua"></div>

    <div class="Box" id="boxtienich"></div>

    <div class="Box" id="boxthongke"></div>
</div>
<div class="both"></div>